package Athena::CellFormat;

use strict;

require Exporter;
use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
@ISA = qw(Exporter);

%EXPORT_TAGS = ( 'all' => [ qw(cellFormatInit cellColor colColor colTextColor) ]);
@EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} });
@EXPORT = ( @{ $EXPORT_TAGS{'all'} });

sub new {
  
  # Get the class name
  my $stInvocant = shift(@_);
  my $stClass = ref($stInvocant) || $stInvocant;
  
  # Create the current instance and bless into class
  my $rSelf = { };
  bless($rSelf,$stClass);
  $rSelf->cellFormatInit();
  return $rSelf;
}

sub cellFormatInit {
  my $rSelf = shift(@_);
  $rSelf->{_cell_color} = "0";
  $rSelf->{_col_color} = "0";
  $rSelf->{_col_text_color} = "0";
}

sub cellColor {
  my $rSelf = shift(@_);
  my $stReset = shift(@_);
  if (defined ($stReset)) {
    $rSelf->{_cell_color} = "1";
  }
  my $stOnCell = "#dddddd";
  my $stOffCell = "#eeeeee";

  if ($rSelf->{_cell_color} eq "1") {
    $rSelf->{_cell_color} = "0";
    return $stOnCell;
  }
  else {
    $rSelf->{_cell_color} = "1";
    return $stOffCell;
  }
}

sub colColor {
  my $rSelf = shift(@_);
  my $stReset = shift(@_);
  if (defined ($stReset)) {
    $rSelf->{_col_color} = "1";
  }
  my $stOnCol = "#ccccdd";
  my $stOffCol = "#eeeeee";

  if ($rSelf->{_col_color} eq "1") {
    $rSelf->{_col_color} = "0";
    return $stOnCol;
  }
  else {
    $rSelf->{_col_color} = "1";
    return $stOffCol;
  }
}

sub colTextColor {
  my $rSelf = shift(@_);
  my $stText = shift(@_);
  my $stReset = shift(@_);
  if (defined ($stReset)) {
    $rSelf->{_col_text_color} = "1";
  }
  my $stOnCol = "#000080";
  my $stOffCol = "#000000";
  my $stTextReturn = '<font color="';
  if ($rSelf->{_col_text_color} eq "1") {
    $rSelf->{_col_text_color} = "0";
    $stTextReturn .= $stOnCol;
  }
  else {
    $rSelf->{_col_text_color} = "1";
    $stTextReturn .= $stOffCol;
  }
  $stTextReturn .= '">' . $stText . '</font>';
  return $stTextReturn;
}

1;
